package procsim;

import java.awt.*;

public class PaintControlUnit2 extends PaintTab{
    public PaintControlUnit2 (Paint parent){
        super(parent);
        // Coordinates
        Design.CUCNTOut.addCoords(this, 392, 20, 392, 50);
        Design.CUDCOut.addCoords(this, 392, 150, 392, 200);
        Design.CUDCOut169_0.addCoords(this, 265, 200, 265, 230);
        Design.CUDCOut169_0.addCoords(this, 525, 200, 525, 230);
        Design.CUDCOut169_0.addCoords(this, 265, 200, 525, 200);

        Design.L1.addCoords(this, 390, 280, 450, 280);
        Design.L2.addCoords(this, 390, 300, 450, 300);
        Design.regdir.addCoords(this, 390, 320, 450, 320);
        Design.immreg.addCoords(this, 390, 340, 450, 340);
        Design.condCompl.addCoords(this, 390, 360, 450, 360);
        Design.grADROPR.addCoords(this, 390, 380, 450, 380);
        Design.PREKIDCompl.addCoords(this, 525, 470, 525, 430);
        Design.brOPR.addCoords(this, 600, 320, 650, 320);
        Design.branch.addCoords(this, 600, 340, 650, 340);

        // Collections
        elements.add(Design.CTRLSignalsOP);
        elements.add(Design.CTRLSignalsCU);
        elements.add(Design.CUDC);

        lines.add(Design.CUCNTOut);
        lines.add(Design.CUDCOut);
        lines.add(Design.CUDCOut169_0);

        //added Signals
        lines.add(Design.L1);
        lines.add(Design.L2);
        lines.add(Design.immreg);
        lines.add(Design.regdir);
        lines.add(Design.condCompl);
        lines.add(Design.grADROPR);

        lines.add(Design.PREKIDCompl);

        lines.add(Design.brOPR);
        lines.add(Design.branch);
        
        addMouseListener(Design.CTRLSignalsOP);
        addMouseListener(Design.CTRLSignalsCU);
    }
    @Override
    public void paint(Graphics g){
        super.paint(g);
        Graphics2D gnew = (Graphics2D)g;
        Util.saveGraphics(gnew);
        Font f = g.getFont();
        g.setFont(new Font("Arial", Font.PLAIN, 16));
        g.drawString("CTRLSignalsOP", 208, 300);
        g.drawString("CTRLSignalsCU", 468, 330);
        g.setFont(new Font("Arial", Font.ITALIC, 10));
        g.drawString("registers", 142, 257);
        g.drawString("operations", 142, 282);
        g.drawString("interface", 142, 307);
        g.drawString("interrupts", 142, 332);
        g.setFont(f);
        gnew.setColor(Color.GRAY);
        gnew.setStroke(new BasicStroke(1));
        gnew.drawLine(140, 260, 200, 260);
        gnew.drawLine(140, 285, 200, 285);
        gnew.drawLine(140, 310, 200, 310);
        gnew.drawLine(140, 335, 200, 335);
        gnew.drawLine(527, 455, 563, 455);
        gnew.drawLine(392, 350, 415, 350);
        Util.restoreGraphics(gnew);
    }
}
